package com.boot.demofile.config;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Slf4j
@Configuration
public class WebConfigurer implements WebMvcConfigurer {

    @Value("${custconfig.local-path}")
    private String localPath;
    @Autowired
    private CustConfig custConfig;
    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        for (String path:custConfig.getLocalPathList()){
            registry.addResourceHandler("/"+path.replace(":/","")+"/**").addResourceLocations("file:///"+path);
        }
    }
}

